package com.bytz.modules.cms.order.schedule;

import cn.hutool.core.bean.BeanUtil;
import com.bytz.common.system.vo.LoginUser;
import com.bytz.common.util.SecurityUtils;
import com.bytz.modules.cms.order.service.IOrderContractService;
import com.bytz.modules.system.service.ISysUserService;
import com.bytz.modules.system.vo.SysUserVo;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class GenerateContractJob implements Job {

    @Autowired
    private IOrderContractService contractService;

    @Autowired
    ISysUserService sysUserService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) {

        SysUserVo syscall = sysUserService.getUserByName("syscall");
        SecurityUtils.setLoginUser(BeanUtil.copyProperties(syscall, LoginUser.class));

        contractService.batchGenerate();

        SecurityUtils.setLoginUser(null);
    }
}
